<!--设置-发起跟单默认佣金-->
<template>
  <div class="bg">

    <div v-if="active" class="content bg3">

      <text class="title font36 text1">{{T('修改默认佣金')}}</text>


      <div class="height60"></div>
      <div class="row acenter">
        <text class="font28 text2">{{T('每日佣金')}}</text>
        <div class="all"></div>
        <div :class="['input', 'bg1', this.select ? 'main-b1' : '']">
          <input class="input-content font28 text1" v-model="defaultCommission" type="number" :placeholder="T('每日佣金')" @focus="(select=true)" @blur="(select=false)">
          <div class="input-line no1"></div>
          <text class="font28 text2">{{'VTN'}}</text>
        </div>
      </div>
      
      <LSwitc class="switc" :title="T('是否包含提现权益')" v-model="isVtnEquity"></LSwitc>

      <text class="tips font20 text2">* {{T('默认值修改仅对新发跟单策略，原有策略不受影响')}}</text>

      <div class="row ">
        <div class="but no1" @click="cancelClick"><text class="font32 text1">{{T('取消')}}</text></div>
        <div class="all"></div>
        <div class="but main1" @click="okClick"><text class="font32 text1">{{T('确认')}}</text></div>
      </div>
    </div>
  </div>
</template>

<script>


//组件
import LSwitc from "@/public/view/LSwitc"; 

//功能
import navigator from "@/_js/navigator"; 
import modal from "@/_js/modal";
import math from "@/_js/math";

const globalEvent = weex.requireModule('globalEvent');
import weexHttp from "@/_js/https"; ;
const weexFunction = weex.requireModule("WeexFunction");

import I18N from "@/_i18n/i18n";
var T = I18N.t;

export default {

  components: {
    LSwitc,
  },
  data() {
    return {
      T:T,
      select:false, //选中
      active:false,
      defaultCommission:'', //默认佣金
      isVtnEquity:false, //true 带提现权益
    };
  },

  mounted() {

    this.defaultCommission = navigator.getParam("defaultCommission");
    this.isVtnEquity = navigator.getParam("isVtnEquity");
    this.active = true;
  },

  methods: {

    //http修改默认佣金
    httpUpdateDefaultCommission(){
      modal.showLoad();
      var param = {'defaultCommission':this.defaultCommission, 
                   'isVtnEquity':this.isVtnEquity};
      weexHttp.postX("follow/updateDefaultCommission",param,true,(data)=>{
        modal.hideLoad();
        if(data.status == 200){
          modal.toast(T('修改成功'));

          const aPost = new BroadcastChannel("SetFollwMoney");
          aPost.postMessage(param);
          this.cancelClick();
        } else {
          modal.toast(data.msg);
        }
      });
    },

    /********************************** 点击触发*/
    //取消点击
    cancelClick(){
      navigator.dismiss();
    },

    //确定点击
    okClick(){

      if (this.defaultCommission.length == 0) {
        modal.toast(T('请输入每日佣金'));
        return;
      } else if (math.getNumber(this.defaultCommission) > 200) {
        modal.toast(T('每日佣金不可超过200VTN'));
        return;
      }
      this.httpUpdateDefaultCommission();
    },
  }
}

</script>


<style src="@/_css/style.css"></style>
<style scoped>

.bg {
  flex-direction: row;
  justify-content: center;
  align-items: center;
  width: 750px;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;

  background-color: rgba(0, 0, 0, 0.3);
}

.content {
  flex-direction: column;
  width: 642px;
  background: #202B46;
  border-radius: 4px;

  padding-top: 60px;
  padding-bottom: 60px;
  padding-left: 60px;
  padding-right: 60px;
}

.title {
  flex: 1;
  text-align: center;
}

.switc{
  width: 522px;
  margin-top: 40px;
}

.tips{
  width: 522px;
  margin-top:40px;
}

.but{
  flex-direction: row;
  justify-content: center;
  align-items: center;
  width: 240px;
  height: 80px;
  border-radius: 4px;
  margin-top: 40px;
}

/************ 输入框*/
.input{
  flex-direction: row;
  align-items: center;
  width: 372px;
  height: 88px;
  border-radius: 44px;

  border-width: 2px;
  border-color: transparent;

  padding-left: 40px;
  padding-right: 30px;
}
.input-content{
  flex: 1;
  height: 88px;
  placeholder-color:#6E7488;
}
.input-line{
  width: 2px;
  height: 32px;
  margin-left: 20px;
  margin-right: 20px;
}


/************ 间距*/
.height60{
  height: 60px;
}
</style>